package top.xierongsheng.user.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import top.xierongsheng.user.dto.groups.Create;
import top.xierongsheng.user.dto.groups.ResetPwd;
import top.xierongsheng.user.dto.groups.Update;
import top.xierongsheng.user.dto.groups.UpdateStatus;
import top.xierongsheng.user.validate.ValidArea;
import top.xierongsheng.user.validate.ValidRole;

import jakarta.validation.constraints.*;

import java.io.Serial;
import java.io.Serializable;

@Data
@Schema(description = "用户数据Dto")
@Accessors(chain = true)
public class UserDto implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(title = "用户ID")
    @NotBlank(message = "用户Id不能为空", groups = {Update.class, UpdateStatus.class, ResetPwd.class})
    private String id;

    @Schema(description = "账号")
    @NotBlank(message = "账号不能为空", groups = {Update.class, Create.class})
    private String account;

    @Schema(description = "密码")
    @NotBlank(message = "密码不能为空", groups = {Update.class, Create.class})
    private String password;

    @Schema(description = "姓名")
    @NotBlank(message = "姓名不能为空", groups = {Update.class, Create.class})
    private String name;

    @Schema(description = "昵称")
    @NotBlank(message = "昵称不能为空", groups = {Update.class, Create.class})
    private String nickname;

    @Schema(title = "用户状态", description = "(0：删除 1：启用  2：禁用)")
    @NotNull(message = "状态不能为空", groups = {UpdateStatus.class})
    @Size(max = 2, message = "status值必须为0-2内的数值", groups = {UpdateStatus.class})
    private Integer status;

    @Schema(description = "身份证号")
    @NotBlank(message = "身份证号不能为空", groups = {Update.class, Create.class})
    private String idCard;

    @Schema(description = "手机号")
    @NotBlank(message = "手机号不能为空", groups = {Update.class, Create.class})
    private String phone;

    @Schema(title = "性别", description = "(1: 女  2: 男)")
    @NotNull(message = "性别不能为空", groups = {Update.class, Create.class})
    private Integer sex;

    @Schema(description = "角色ID")
    @NotBlank(message = "角色id不能为空", groups = {Update.class, Create.class})
    @ValidRole(groups = {Update.class, Create.class})
    private String roleId;

    @Schema(description = "地区编码")
    @NotNull(message = "地区id不能为空", groups = {Update.class, Create.class})
    @ValidArea(groups = {Update.class, Create.class})
    private Integer areaId;

    @Schema(description = "详细地址")
    @NotBlank(message = "地区详细不能为空", groups = {Update.class, Create.class})
    private String areaDesc;
}
